#!/usr/bin/env python
# coding: utf-8
# Copyright (c) 2023 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

if ((defined(ark_standalone_build) && ark_standalone_build) ||
    (defined(ark_static_standalone_build) && ark_static_standalone_build)) {
  import("//arkcompiler/runtime_core/static_core/ark_config.gni")
} else {
  import(
      "//build/config/components/runtime_core/static_core/ark_common_config.gni")
}

action("build_declgen") {
  sources = [
    "package.json",
    "src/ASTAutofixer.ts",
    "src/ASTChecker.ts",
    "src/ASTTransformer.ts",
    "src/Declgen.ts",
    "src/TestRunner.ts",
    "src/cli/CLI.ts",
    "src/cli/DeclgenCLI.ts",
    "src/cli/TestRunnerCLI.ts",
    "src/compiler/Compiler.ts",
    "src/generateInteropDecls.ts",
    "src/main.ts",
    "src/utils/ASTHelpers.ts",
    "src/utils/Extension.ts",
    "src/utils/LogTscDiagnostics.ts",
  ]

  script = "compile_declgen.py"
  args = [
    rebase_path(get_path_info("./", "abspath")),
    rebase_path("${target_out_dir}"),
  ]

  outputs = [ "${target_out_dir}/panda-declgen-1.0.0.tgz" ]
}

if (!(defined(ark_static_standalone_build) && ark_static_standalone_build)) {
  ohos_shared_headers("build_declgen_etc") {
    include_dirs = []
    deps = [ ":build_declgen" ]
    part_name = "runtime_core"
    subsystem_name = "arkcompiler"
  }
}
